
package leetcode;

public class Q2451 {
    static boolean isSame(int a[], int b[]) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] != b[i]) {
                return false;
            }
        }
        return true;
    }

    public String oddString(String[] words) {
        int[][] changed = new int[words.length][words[0].length() - 1];
        for (int i = 0; i < words.length; i++) {
            for (int j = 0; j < words[0].length() - 1; j++) {
                changed[i][j] = words[i].charAt(j + 1) - words[i].charAt(j);
            }
        }

        int[] same;
        if (isSame(changed[0], changed[1])) {
            same = changed[0];
        } else if (isSame(changed[1], changed[2])) {
            same = changed[1];
        } else {
            same = changed[2];
        }

        for (int i = 0; i < changed.length; i++) {
            if (!isSame(changed[i], same)) {
                return words[i];
            }
        }
        return "";
    }

    public static void main(String[] args) {
        Q2451 sl = new Q2451();
    }
}